package com.tuteng.administrator.ashospital.AdapterManger;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;




import java.util.List;

/**
 * Created by 黄启位 on 2016/3/7.
 */
public abstract class CommonAdapter<T> extends BaseAdapter{
    protected Context mContext;
    protected   List<T>mDatas;
    protected LayoutInflater mInfater;
    private  int layoutId;
    public CommonAdapter(Context context,List<T>datas,int layoutId) {
        this.mContext=context;
        this.mDatas=datas;
        mInfater=LayoutInflater.from(context);
        this.layoutId=layoutId;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public T getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public  View getView(int position, View convertView, ViewGroup parent){
        ViewHolder holder=ViewHolder.get(mContext, convertView, parent, layoutId, position);
        convert(holder, getItem(position));

        return holder.getmConvertView();
    } ;
    public  abstract  void convert (ViewHolder holder,T t);
}
